import * as mars3d from 'mars3d'
import type { MapStateType } from '@/components/MMap/types.ts'

// 离线地图方法
export const addOfflineGlobalLayer = (MapState: MapStateType) => {
  const { staticServerIP, instance: map } = MapState
  // 全球卫星底图
  const GlobalLayer = new mars3d.layer.XyzLayer({
    url: staticServerIP + '/digitalSentinel/uploadPath/global-3/{z}/{x}/{y}.png',
    minimumLevel: 0,
    maximumLevel: 4,
    isInitial: true, //表示初始地图图层， 在后续业务操作中不需要删除
  } as any)
  map?.addLayer(GlobalLayer)
}

export const addOfflineProvinceLayer = (MapState: MapStateType) => {
  const { staticServerIP, instance: map } = MapState
  // 河北省卫星底图
  const ProvinceLayer = new mars3d.layer.XyzLayer({
    url: staticServerIP + '/project-deploy/offline-map/jibei-map/{z}/{x}/{y}.png',
    minimumLevel: 0,
    maximumLevel: 13,
    isInitial: true, //表示初始地图图层， 在后续业务操作中不需要删除
  } as any)
  map?.addLayer(ProvinceLayer)
}

export const addOfflineLayer = (MapState: MapStateType) => {
  addOfflineGlobalLayer(MapState)
  addOfflineProvinceLayer(MapState)
}
